<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <p>{{user.fullName}}</p>
    <p>{{num1}}+{{num2}}={{total}}</p>
  </div>
</body>
<script src="../dist/vue.js"></script>
<script>
  const vm = new Vue({
    el: '#app',
    data: {
      user: {
        firstName: '尤',
        lastName: '小右',
        fullName: ''
      },
      num1: 2,
      num2: 3
    },
    computed: {
      total() {
        return this.num1 + this.num2
      }
    },
    watch: {
      user: {
        handler(val, oldVal) {
          this.user.fullName = val.firstName + ' ' + val.lastName
        },
        immediate: true,
        deep: true
      }
    }
  })

</script>

</html>
